const recursion = (menus) => {
	let ids = new Array();
	try {
		menus.forEach((e) => {
			addChild(e, ids);
		});
		return ids;
	} catch (e) {
		console.info('类型错误', e);
	}
};

function addChild(menu, ids) {
	ids.push(menu.id);
	if (menu.children && menu.children.length) {
		menu.children.forEach((e) => {
			ids.push(e.id);
			if (e.children && e.children.length > 0) {
				addChild(e, ids);
			}
		});
		return ids;
	}
}

export { recursion };
